package com.yanqu.road.server.timer.systemgroup;

import com.yanqu.road.server.manager.systemgroup.Cross3SystemWeekGroupMatchMgr;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.executor.GeneralTask;

public class CrossSystemGroupTask extends GeneralTask {

    private static long lastCheckUploadTime = System.currentTimeMillis();

    private static long lastCheckGroupingTime = System.currentTimeMillis();

    @Override
    public void doRun() {


        try {
            if(System.currentTimeMillis() - lastCheckUploadTime > DateHelper.MINUTE_MILLIONS * 1) {
                lastCheckUploadTime = System.currentTimeMillis();
                Cross3SystemWeekGroupMatchMgr.checkUploadData();
            }
        } catch (Exception e) {
            getLOGGER().error("checkUploadData error:", e);
        }

        try {
            if(System.currentTimeMillis() - lastCheckGroupingTime > DateHelper.MINUTE_MILLIONS * 1) {
                lastCheckGroupingTime = System.currentTimeMillis();
                Cross3SystemWeekGroupMatchMgr.checkGrouping();

                try {
                    Cross3SystemWeekGroupMatchMgr.syncMatchGroup();
                } catch (Exception e) {
                    getLOGGER().error("syncMatchGroup error:", e);
                }
            }
        } catch (Exception e) {
            getLOGGER().error("checkGrouping error:", e);
        }


    }
}
